package com.example.yibu;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.HashMap;

import manager.ConnectionManager;

import MLTest.RequestIn1;
import MLTest.RequestIn2;
import MLTest.ResponseIn1;
import MLTest.ResponseIn2;
import MLTool.MHttpClient;
import SyncPool.HttpLifeCycleInterface;
import SyncPool.RequestType;
import SyncPool.URLConfig;

public class MainActivity  implements HttpLifeCycleInterface{

 

	public static void main(String[] string){
		
 		
 		 String para = null;
		try {
			para = "action="+ URLEncoder.encode("Member.Member", "UTF-8")+
			         "&func="+URLEncoder.encode("Login", "UTF-8")+
			         "&phone="+URLEncoder.encode("15093201628", "UTF-8")+
			         "&v="+URLEncoder.encode("1.1.10", "UTF-8")+
			         "&password="+URLEncoder.encode(MD5.Md5("111111", DesConstants.YAN).toUpperCase(), "UTF-8")+
			         "&terminal="+URLEncoder.encode("100033", "UTF-8");
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		String desCode = null;
         try {
			  desCode = DesConstants.EncryptAsDoNet(para,DesConstants.AESKey);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
 		for(int i=0;i<30000;i++){
 			
 		    URLConfig config=new URLConfig();
 	 		config.setRequestType(RequestType.POST);
 	 		config.setUrl(com.example.yibu.URLConfig.normal_url);
 	 		HashMap<String, Object> h=new HashMap<String, Object>();
 	 		h.put("para", desCode);
 	  		config.setMap(h);
 	   		
 			ConnectionManager requstManager=new MHttpClient().
 					addRequestInterceptor(new RequestIn1())
 					.addRequestInterceptor(new RequestIn2())
 					.addResponseInterceptor(new ResponseIn1())
 					.addResponseInterceptor(new ResponseIn2())
 					.newRequest(config, new MainActivity());
 			
 			
 		}
     
		
 		
	}
	
	
	
	public void start(long total) {
		// TODO Auto-generated method stub
		
	}

	public void current(long current, long total) {
		// TODO Auto-generated method stub
		
	}

	public void stop() {
		// TODO Auto-generated method stub
		
	}

	public void finish() {
		// TODO Auto-generated method stub
		
	}

	public void success(String result) {
		// TODO Auto-generated method stub
        String message = DesConstants.DecryptDoNet(result,DesConstants.AESKey);
        System.out.println("message="+message);
	}

	public void fail(Exception e) {
		// TODO Auto-generated method stub
		
	}

	 

}
